<template>
  <div>
    <a-card :bordered="false" style="margin-bottom: 10px">
      <!-- 条件搜索 -->
      <div class="table-page-search-wrapper">
        <a-form :labelCol="labelCol" :wrapperCol="wrapperCol" ref="queryForm">
          <a-row :gutter="10">
            <a-col :span="4">
              <a-form-item label="部门" prop="type">
                <a-tree-select
                  v-model="queryParam.deptId"
                  style="width: 100%"
                  :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                  :tree-data="deptOptions"
                  placeholder="请选择"
                  :replaceFields="{
                    children: 'children',
                    title: 'menuName',
                    key: 'id',
                    value: 'id',
                  }"
                  @change="onMenuTreeChange"
                  allow-clear
                >
                </a-tree-select>
              </a-form-item>
            </a-col>
            <a-col :span="4">
              <a-form-item label="客户经理">
                <a-select
                  placeholder="请选择客户经理"
                  v-model="queryParam.userId"
                  :getPopupContainer="
                    (triggerNode) => {
                      return triggerNode.parentNode || document.body;
                    }
                  "
                  style="width: 100%"
                  allow-clear
                >
                  <a-select-option
                    v-for="d in userNamesList"
                    :key="d.name"
                    :value="d.id"
                    >{{ d.name }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="4">
              <a-form-item label="线索来源" prop="type">
                <a-select
                  placeholder="选择线索来源"
                  v-model="queryParam.laiyuan"
                  style="width: 100%"
                  allow-clear
                >
                  <a-select-option
                    v-for="(d, index) in laiyuanOptions"
                    :key="index"
                    :value="d.dictValue"
                    >{{ d.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="4">
              <a-form-item label="状态" prop="status">
                <a-select
                  placeholder="选择状态"
                  v-model="queryParam.status"
                  style="width: 100%"
                  allow-clear
                >
                  <a-select-option
                    v-for="(d, index) in statusOptions"
                    :key="index"
                    :value="d.dictValue"
                    >{{ d.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="4">
              <a-form-item label="客户姓名">
                <a-input
                  v-model="queryParam.cusName"
                  placeholder="请输入客户姓名"
                  allow-clear
                  @keyup.enter.native="handleQuery"
                />
              </a-form-item>
            </a-col>
            <a-col :span="4">
              <a-form-item label="客户电话">
                <a-input
                  v-model="queryParam.phone"
                  placeholder="请输入客户电话"
                  @keyup.enter.native="handleQuery"
                  allow-clear
                />
              </a-form-item>
            </a-col>
            <a-col :span="4">
              <a-form-item label="进线时间">
                <a-range-picker
                  style="width: 100%"
                  v-model="dateRangeReceiveTime"
                  valueFormat="YYYY-MM-DD"
                  format="YYYY-MM-DD"
                  allow-clear
                />
              </a-form-item>
            </a-col>
            <a-col :span="4">
              <a-form-item label="城市区域">
                <a-input
                  v-model="queryParam.cityName"
                  placeholder="请输入城市区域"
                  allow-clear
                />
              </a-form-item>
            </a-col>

            <a-col>
              <span
                class="table-page-search-submitButtons"
                style="float: right"
              >
                <a-button type="primary" @click="handleQuery"
                  ><a-icon type="search" />查询</a-button
                >
                <a-button style="margin-left: 8px" @click="resetQuery"
                  ><a-icon type="redo" />刷新</a-button
                >
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </a-card>
    <a-card
      :bordered="false"
      class="table-card"
      style="min-height: calc(100vh - 400px)"
    >
      <biz-customer-add-form
        v-if="showAddImportModal"
        ref="bizCustomerAddForm"
        @ok="getList"
        @close="showAddImportModal = false"
      />
      <!--跟进记录-->
      <biz-customer-info-shadow-form
        v-if="showShadowModal"
        ref="bizCustomerInfoShadowForm"
        :typeOptions="typeOptions"
        :levelOptions="levelOptions"
        :progressOptions="progressOptions"
        :statusOptions="statusOptions"
        :ideasTypeOptions="ideasTypeOptions"
        :zxInfoOptions="zxInfoOptions"
        :zhichanInfoOptions="zhichanInfoOptions"
        :genjinQuckitInputOptions="genjinQuckitInputOptions"
        :sexOptions="sexOptions"
        :fujianTypeOptions="fujianTypeOptions"
        @ok="getList"
        @close="showShadowModal = false"
        :eidtshow="true"
      />
      <a-tabs default-active-key="0" @change="callback">
        <a-tab-pane key="0" tab="广告线索">
          <advance-table
            title=" "
            :pagination="{
              current: queryParam.pageNum,
              pageSize: queryParam.pageSize,
              total: total,
              showSizeChanger: true,
              showLessItems: true,
              showQuickJumper: true,
              showTotal: (total, range) =>
                `第 ${range[0]}-${range[1]} 条，总计 ${total} 条`,
              onChange: changeSize,
              onShowSizeChange: onShowSizeChange,
              pageSizeOptions: pageSizeOptions,
            }"
            tableKey="base-bizCustomer-index-table"
            rowKey="id"
            size="middle"
            @refresh="getList"
            :columns="toColumns"
            :data-source="bizCustomerList"
            :loading="loading"
            :format-conditions="true"
            :row-selection="{
              selectedRowKeys: selectedRowKeys,
              onChange: onSelectChange,
            }"
            :scroll="{ x: '100%' }"
          >
            <div class="table-operations" slot="button">
              <a-button type="primary" @click="handleAdd">
                <a-icon type="cloud-upload" />导入数据
              </a-button>
            </div>

            <span slot="status" slot-scope="{ text, record }">
              <a-tag
                v-if="text == '-2'"
                color="#2db7f5"
                @click="handleShare(record)"
                >{{ statusFormat(record) }}</a-tag
              >
              <a-tag v-else-if="text == '7'">{{ statusFormat(record) }}</a-tag>
              <a-tag
                v-else-if="text == '-77' || text == '-88'"
                @click="handleShare(record)"
                color="#f50"
                >{{ statusFormat(record) }}</a-tag
              ><a-tag v-else color="#87d068">已分配</a-tag>
            </span>

            <span slot="cusName" slot-scope="{ text, record }">
              <a @click="handleShadow(record)" style="color: #f56c6c">
                {{ text }}
              </a>
              <a-icon
                type="star"
                v-if="record.isHeart == 2"
                theme="filled"
                style="color: #f50; font-size: 14px; margin-left: 5px"
                @click="handleHeartCancel(record)"
              ></a-icon>
              <a-icon
                type="star"
                v-else
                style="font-size: 14px; margin-left: 5px"
                @click="handleHeart(record)"
              ></a-icon>
            </span>
            <span slot="phone" slot-scope="{ text, record }">
              <a
                @click="handleShadow(record)"
                v-if="record.phone"
                style="color: #f56c6c"
              >
                {{ text.substring(0, 3) + "****" + text.substring(7, 11) }}
              </a>
            </span>
            <span slot="rowindex" slot-scope="{ index }">
              {{ index + 1 }}
            </span>
            <span slot="type" slot-scope="{ record }">
              {{ typeFormat(record) }}
            </span>
            <span slot="level" slot-scope="{ record }">
              <a-rate v-model="record.level" />
            </span>
            <span slot="progress" slot-scope="{ record }">
              {{ busProgressFormat(record) }}
            </span>
            <span slot="amount" slot-scope="{ text }">
              ¥ {{ parseFloat(text || 0).toFixed(2) }}
            </span>
          </advance-table>
        </a-tab-pane>
        <a-tab-pane key="1" tab="重复线索">
          <advance-table
            title=" "
            :pagination="{
              current: queryParam.pageNum,
              pageSize: queryParam.pageSize,
              total: total,
              showSizeChanger: true,
              showLessItems: true,
              showQuickJumper: true,
              showTotal: (total, range) =>
                `第 ${range[0]}-${range[1]} 条，总计 ${total} 条`,
              onChange: changeSize,
              onShowSizeChange: onShowSizeChange,
            }"
            tableKey="base-bizCustomer-index-table"
            rowKey="id"
            size="middle"
            @refresh="getList"
            :columns="toColumns"
            :data-source="bizCustomerList"
            :loading="loading"
            :format-conditions="true"
            :row-selection="{
              selectedRowKeys: selectedRowKeys,
              onChange: onSelectChange,
            }"
            :scroll="{ x: '100%' }"
          >
            <div class="table-operations" slot="button">
              <!-- <a-button @click="handleAdd" class="addJinjian">
            <a-icon type="plus" />转入我的客户
          </a-button>
          <a-button @click="handleAdd" class="togonghai">
            <a-icon type="rollback" />转入公海
          </a-button> -->
              <!-- <a-button type="primary" @click="handleAdd">
                <a-icon type="cloud-upload" />导入数据
              </a-button> -->

              <!-- <a-button type="" @click="handleDelete">
            <a-icon type="delete" />黑名单
          </a-button> -->
            </div>

            <span slot="status" slot-scope="{ text, record }">
              <a-tag
                v-if="text == '-2'"
                color="#2db7f5"
                @click="handleShare(record)"
                >{{ statusFormat(record) }}</a-tag
              >
              <a-tag v-else-if="text == '7'">{{ statusFormat(record) }}</a-tag>
              <a-tag
                v-else-if="text == '-77' || text == '-88'"
                @click="handleShare(record)"
                color="#f50"
                >{{ statusFormat(record) }}</a-tag
              ><a-tag v-else color="#87d068">已分配</a-tag>
            </span>

            <span slot="cusName" slot-scope="{ text, record }">
              <a @click="handleShadow(record)" style="color: #f56c6c">
                {{ text }}
              </a>
            </span>
            <span slot="phone" slot-scope="{ text, record }">
              <a
                @click="handleShadow(record)"
                v-if="record.phone"
                style="color: #f56c6c"
              >
                {{ text.substring(0, 3) + "****" + text.substring(7, 11) }}
              </a>
            </span>
            <span slot="rowindex" slot-scope="{ index }">
              {{ index + 1 }}
            </span>
            <span slot="type" slot-scope="{ record }">
              {{ typeFormat(record) }}
            </span>
            <span slot="level" slot-scope="{ record }">
              <a-rate v-model="record.level" />
            </span>
            <span slot="progress" slot-scope="{ record }">
              {{ busProgressFormat(record) }}
            </span>
            <span slot="amount" slot-scope="{ text }">
              ¥ {{ parseFloat(text || 0).toFixed(2) }}
            </span>
          </advance-table>
        </a-tab-pane>
        <a-tab-pane key="2" tab="其他线索">
          <advance-table
            title=" "
            :pagination="{
              current: queryParam.pageNum,
              pageSize: queryParam.pageSize,
              total: total,
              showSizeChanger: true,
              showLessItems: true,
              showQuickJumper: true,
              showTotal: (total, range) =>
                `第 ${range[0]}-${range[1]} 条，总计 ${total} 条`,
              onChange: changeSize,
              onShowSizeChange: onShowSizeChange,
              pageSizeOptions: pageSizeOptions,
            }"
            tableKey="base-bizCustomer-index-table"
            rowKey="id"
            size="middle"
            @refresh="getList"
            :columns="toColumns"
            :data-source="bizCustomerList"
            :loading="loading"
            :format-conditions="true"
            :row-selection="{
              selectedRowKeys: selectedRowKeys,
              onChange: onSelectChange,
            }"
            :scroll="{ x: '100%' }"
          >
            <div class="table-operations" slot="button">
              <!-- <a-button @click="handleAdd" class="addJinjian">
            <a-icon type="plus" />转入我的客户
          </a-button>
          <a-button @click="handleAdd" class="togonghai">
            <a-icon type="rollback" />转入公海
          </a-button> -->
              <!-- <a-button type="primary" @click="handleAdd">
                <a-icon type="cloud-upload" />导入数据
              </a-button> -->
              <!-- <a-button @click="handleExport">
            <a-icon type="cloud-download" />导出
          </a-button> -->
              <!-- <a-button type="" @click="handleDelete">
            <a-icon type="delete" />黑名单
          </a-button> -->
            </div>

            <span slot="status" slot-scope="{ text, record }">
              <a-tag
                v-if="text == '-2'"
                color="#2db7f5"
                @click="handleShare(record)"
                >{{ statusFormat(record) }}</a-tag
              >
              <a-tag v-else-if="text == '7'">{{ statusFormat(record) }}</a-tag>
              <a-tag
                v-else-if="text == '-77' || text == '-88'"
                @click="handleShare(record)"
                color="#f50"
                >{{ statusFormat(record) }}</a-tag
              ><a-tag v-else color="#87d068">已分配</a-tag>
            </span>

            <span slot="cusName" slot-scope="{ text, record }">
              <a @click="handleShadow(record)" style="color: #f56c6c">
                {{ text }}
              </a>
            </span>
            <span slot="phone" slot-scope="{ text, record }">
              <a
                @click="handleShadow(record)"
                v-if="record.phone"
                style="color: #f56c6c"
              >
                {{ text.substring(0, 3) + "****" + text.substring(7, 11) }}
              </a>
            </span>
            <span slot="rowindex" slot-scope="{ index }">
              {{ index + 1 }}
            </span>
            <span slot="type" slot-scope="{ record }">
              {{ typeFormat(record) }}
            </span>
            <span slot="level" slot-scope="{ record }">
              <a-rate v-model="record.level" />
            </span>
            <span slot="progress" slot-scope="{ record }">
              {{ busProgressFormat(record) }}
            </span>
            <span slot="amount" slot-scope="{ text }">
              ¥ {{ parseFloat(text || 0).toFixed(2) }}
            </span>
          </advance-table>
        </a-tab-pane>
        <a-tab-pane key="3" tab="全部线索">
          <advance-table
            title=" "
            :pagination="{
              current: queryParam.pageNum,
              pageSize: queryParam.pageSize,
              total: total,
              showSizeChanger: true,
              showLessItems: true,
              showQuickJumper: true,
              showTotal: (total, range) =>
                `第 ${range[0]}-${range[1]} 条，总计 ${total} 条`,
              onChange: changeSize,
              onShowSizeChange: onShowSizeChange,
            }"
            tableKey="base-bizCustomer-index-table"
            rowKey="id"
            size="middle"
            @refresh="getList"
            :columns="toColumns"
            :data-source="bizCustomerList"
            :loading="loading"
            :format-conditions="true"
            :row-selection="{
              selectedRowKeys: selectedRowKeys,
              onChange: onSelectChange,
            }"
            :scroll="{ x: '100%' }"
          >
            <div class="table-operations" slot="button">
              <!-- <a-button @click="handleAdd" class="addJinjian">
            <a-icon type="plus" />转入我的客户
          </a-button>
          <a-button @click="handleAdd" class="togonghai">
            <a-icon type="rollback" />转入公海
          </a-button> -->
              <!-- <a-button type="primary" @click="handleAdd">
                <a-icon type="cloud-upload" />导入数据
              </a-button> -->
              <a-button @click="handleExport">
                <a-icon type="cloud-download" />导出全部
              </a-button>
              <!-- <a-button type="" @click="handleDelete">
            <a-icon type="delete" />黑名单
          </a-button> -->
            </div>

            <span slot="status" slot-scope="{ text, record }">
              <a-tag
                v-if="text == '-2'"
                color="#2db7f5"
                @click="handleShare(record)"
                >{{ statusFormat(record) }}</a-tag
              >
              <a-tag v-else-if="text == '7'">{{ statusFormat(record) }}</a-tag>
              <a-tag
                v-else-if="text == '-77' || text == '-88'"
                @click="handleShare(record)"
                color="#f50"
                >{{ statusFormat(record) }}</a-tag
              ><a-tag v-else color="#87d068">已分配</a-tag>
            </span>

            <span slot="cusName" slot-scope="{ text, record }">
              <a @click="handleShadow(record)" style="color: #f56c6c">
                {{ text }}
              </a>
            </span>
            <span slot="phone" slot-scope="{ text, record }">
              <a
                @click="handleShadow(record)"
                v-if="record.phone"
                style="color: #f56c6c"
              >
                {{ text.substring(0, 3) + "****" + text.substring(7, 11) }}
              </a>
              <!-- {{ text }} -->
            </span>
            <span slot="rowindex" slot-scope="{ index }">
              {{ index + 1 }}
            </span>
            <span slot="type" slot-scope="{ record }">
              {{ typeFormat(record) }}
            </span>
            <span slot="level" slot-scope="{ record }">
              <a-rate v-model="record.level" />
            </span>
            <span slot="progress" slot-scope="{ record }">
              {{ busProgressFormat(record) }}
            </span>
            <span slot="amount" slot-scope="{ text }">
              ¥ {{ parseFloat(text || 0).toFixed(2) }}
            </span>
          </advance-table>
        </a-tab-pane>
      </a-tabs>
    </a-card>
    <a-modal
      :visible="visible"
      title="选择转移到客户经理"
      v-if="visible"
      width="65%"
      @ok="handleOk"
      @cancel="handleCancel"
      :dialog-style="{ top: '10px' }"
      style="height: 60vh"
    >
      <change-user
        @getUser="handleManualShare"
        :isCheckBox="false"
        :isKefu="2"
      />
    </a-modal>
  </div>
</template>
<script>
import {
  alllist,
  delBizCustomer,
  exportBizCustomer,
  manualShare,
} from "@/api/biz/bizCustomer";
import { listUser } from "@/api/system/user";
import { listDeptTree } from "@/api/system/dept";
import AdvanceTable from "@/components/pt/table/AdvanceTable";
import BizCustomerInfoShadowForm from "@/views/biz/customer/modules/BizCustomerInfoShadowForm";
import ChangeUser from "@/views/system/user/modules/ChangeUser";
import BizCustomerAddForm from "@/views/biz/customer/modules/BizCustomerAddForm";

export default {
  name: "BizCustomer",
  components: {
    AdvanceTable,
    BizCustomerInfoShadowForm,
    ChangeUser,
    BizCustomerAddForm,
  },
  data() {
    return {
      visible: false,
      showAddModal: false,
      showEditModal: false,
      showShadowModal: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 选中的主键集合
      selectedRowKeys: [],
      // 选中的数据集合
      selectedRows: [],
      // 高级搜索 展开/关闭
      advanced: false,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // label的百分比
      labelCol: { span: 6 },
      // 内容区域的百分比
      wrapperCol: { span: 18 },
      // 左心房客户推送信息表格数据
      bizCustomerList: [],
      // 状态字典
      statusOptions: [],
      // 申请类型字典
      typeOptions: [],
      // 业务进度
      progressOptions: [],
      levelOptions: [],
      ideasTypeOptions: [],
      // 征信信息
      zxInfoOptions: [],
      zhichanInfoOptions: [],
      genjinQuckitInputOptions: [],
      ownTypeOptions: [],
      fujianTypeOptions: [],
      // 性别
      sexOptions: [],
      showAddImportModal: false,
      laiyuanOptions: [],
      pageSizeOptions: ["10", "20", "30", "40", "100", "200", "300", "400"],
      // 部门信息
      deptOptions: [],
      // 查询参数
      queryParam: {
        pageNum: 1,
        pageSize: 10,
        status: undefined,
        laiyuanType: "1",
        isRep: "0",
      },
      // customerInfo
      customerInfo: {},
      userNamesList: [],
      // 时间
      dateRange: [],
      dateRangeShare: [],
      dateRangeReceiveTime: [],
      toColumns: [],
      columns: [
        {
          title: "序号",
          dataIndex: "rowindex",
          ellipsis: true,
          align: "center",
          width: "50px",
          scopedSlots: { customRender: "rowindex" },
        },
        {
          title: "首次进线",
          dataIndex: "createTime",
          align: "center",
          width: "170px",
        },
        {
          title: "客户姓名",
          dataIndex: "cusName",
          ellipsis: true,
          align: "left",
          width: "120px",
          scopedSlots: { customRender: "cusName" },
        },
        {
          title: "电话",
          dataIndex: "phone",
          ellipsis: true,
          align: "right",
          width: "120px",
          // fixed: "left",
          scopedSlots: { customRender: "phone" },
        },

        {
          title: "城市区域",
          dataIndex: "cityName",
          ellipsis: true,
          align: "center",
          width: "120px",
        },
        {
          title: "申请金额",
          dataIndex: "amount",
          align: "right",
          width: "120px",
          // scopedSlots: { customRender: "amount" },
        },
        {
          title: "车辆品牌",
          dataIndex: "carModel",
          ellipsis: true,
          align: "center",
          width: "120px",
        },
        {
          title: "车牌号",
          dataIndex: "carNo",
          ellipsis: true,
          align: "center",
          width: "110px",
        },
        {
          title: "车辆状态",
          dataIndex: "carStatus",
          align: "left",
          width: "120px",
          ellipsis: true,
        },
        {
          title: "评估价格",
          dataIndex: "pgPrice",
          align: "left",
          width: "120px",
          ellipsis: true,
        },
        {
          title: "客户来源",
          dataIndex: "laiyuan",
          ellipsis: true,
          align: "center",
          width: "100px",
        },
        {
          title: "状态",
          dataIndex: "status",
          align: "center",
          width: "90px",
          ellipsis: true,
          scopedSlots: { customRender: "status" },
        },
        {
          title: "跟进状态",
          dataIndex: "progress",
          ellipsis: true,
          align: "left",
          width: "180px",
          scopedSlots: { customRender: "progress" },
        },
        {
          title: "客户经理",
          dataIndex: "userName",
          ellipsis: true,
          align: "center",
          width: "100px",
        },
        {
          title: "最后跟进内容",
          dataIndex: "genjin",
          ellipsis: true,
          align: "left",
          width: "180px",
        },

        {
          title: "备注",
          dataIndex: "remark",
          ellipsis: true,
          align: "left",
          // width: "280px",
        },
        // {
        //   title: "操作",
        //   dataIndex: "operation",
        //   align: "center",
        //   width: "120px",
        //   scopedSlots: { customRender: "operation" },
        //   fixed: "right",
        // },
      ],
      rpcolumns: [
        {
          title: "序号",
          dataIndex: "rowindex",
          ellipsis: true,
          align: "center",
          width: "50px",
          scopedSlots: { customRender: "rowindex" },
        },
        {
          title: "首次进线",
          dataIndex: "createTime",
          align: "center",
          width: "170px",
        },
        {
          title: "最后进线",
          dataIndex: "receiveTime",
          align: "center",
          width: "170px",
        },
        {
          title: "客户姓名",
          dataIndex: "cusName",
          ellipsis: true,
          align: "left",
          width: "120px",
          scopedSlots: { customRender: "cusName" },
        },
        {
          title: "电话",
          dataIndex: "phone",
          ellipsis: true,
          align: "right",
          width: "120px",
          // fixed: "left",
          scopedSlots: { customRender: "phone" },
        },

        {
          title: "城市区域",
          dataIndex: "cityName",
          ellipsis: true,
          align: "center",
          width: "120px",
        },
        {
          title: "申请金额",
          dataIndex: "amount",
          align: "right",
          width: "120px",
          // scopedSlots: { customRender: "amount" },
        },
        {
          title: "车辆品牌",
          dataIndex: "carModel",
          ellipsis: true,
          align: "center",
          width: "120px",
        },
        {
          title: "车牌号",
          dataIndex: "carNo",
          ellipsis: true,
          align: "center",
          width: "110px",
        },
        {
          title: "车辆状态",
          dataIndex: "carStatus",
          align: "left",
          width: "120px",
          ellipsis: true,
        },
        {
          title: "评估价格",
          dataIndex: "pgPrice",
          align: "left",
          width: "120px",
          ellipsis: true,
        },
        {
          title: "客户来源",
          dataIndex: "laiyuan",
          ellipsis: true,
          align: "center",
          width: "100px",
        },
        {
          title: "状态",
          dataIndex: "status",
          align: "center",
          width: "90px",
          ellipsis: true,
          scopedSlots: { customRender: "status" },
        },
        {
          title: "跟进状态",
          dataIndex: "progress",
          ellipsis: true,
          align: "left",
          width: "180px",
          scopedSlots: { customRender: "progress" },
        },
        {
          title: "客户经理",
          dataIndex: "userName",
          ellipsis: true,
          align: "center",
          width: "100px",
        },
        {
          title: "最后跟进内容",
          dataIndex: "genjin",
          ellipsis: true,
          align: "left",
          width: "180px",
        },

        {
          title: "备注",
          dataIndex: "remark",
          ellipsis: true,
          align: "left",
          // width: "280px",
        },
        // {
        //   title: "操作",
        //   dataIndex: "operation",
        //   align: "center",
        //   width: "120px",
        //   scopedSlots: { customRender: "operation" },
        //   fixed: "right",
        // },
      ],
    };
  },
  created() {
    this.getList();
    this.getDicts("customer_status").then((response) => {
      this.statusOptions = response.data;
    });
    this.getDicts("customer_type").then((response) => {
      this.typeOptions = response.data;
    });
    this.getDicts("bus_progress").then((response) => {
      this.progressOptions = response.data;
    });
    this.getDicts("level_options").then((response) => {
      this.levelOptions = response.data;
    });
    this.getDicts("ideas_type_options").then((response) => {
      this.ideasTypeOptions = response.data;
    });
    this.getDicts("zx_info").then((response) => {
      this.zxInfoOptions = response.data;
    });
    this.getDicts("sys_user_sex").then((response) => {
      this.sexOptions = response.data;
    });
    this.getDicts("zhichan_info").then((response) => {
      this.zhichanInfoOptions = response.data;
    });
    this.getDicts("genjin_quckit_input").then((response) => {
      this.genjinQuckitInputOptions = response.data;
    });
    this.getDicts("own_type").then((response) => {
      this.ownTypeOptions = response.data;
    });
    this.getDicts("fujian_type").then((response) => {
      this.fujianTypeOptions = response.data;
    });
    this.getDicts("bus_type").then((response) => {
      this.laiyuanOptions = response.data;
    });
    this.getDeptList();
  },
  methods: {
    getUserList(deptId) {
      listUser({ deptId: deptId, pageSize: 100 }).then((res) => {
        this.userNamesList = res.data.list;
      });
    },
    onMenuTreeChange(value) {
      console.log(value);
      this.getUserList(value);
    },
    getDeptList() {
      listDeptTree("", 3).then((response) => {
        // this.expandTree(response.data, 3, this.expandedRowKeys);
        this.deptOptions = response.data;
      });
    },
    callback(v) {
      if (v === "0") {
        this.queryParam.isRep = "0";
        this.queryParam.laiyuanType = "1";
      }
      if (v === "1") {
        this.queryParam.isRep = "1";
        this.queryParam.laiyuanType = undefined;
      }

      if (v === "2") {
        this.queryParam.isRep = undefined;
        this.queryParam.laiyuanType = "2";
      }
      if (v === "3") {
        this.queryParam.isRep = undefined;
        this.queryParam.laiyuanType = undefined;
      }
      this.getList();
    },
    // 客户跟踪信息
    handleShadow(record) {
      this.showShadowModal = true;
      this.$nextTick(() =>
        this.$refs.bizCustomerInfoShadowForm.handleShadow(record)
      );
    },
    handleManualShare(user) {
      console.log(user);
      this.customerInfo.userId = user[0].id;
      console.log(this.customerInfo.userId);
    },
    handleShare(rows) {
      this.visible = true;
      this.customerInfo.id = rows.id;
    },
    getTeacher(item) {
      this.teacherId = item.teacherId;
      this.teacherName = item.teacherName;
    },
    /** 查询左心房客户推送信息列表 */
    getList() {
      this.loading = true;

      // const dateRangeReceiveTime = this.dateRangeReceiveTime;

      var queryForm = this.addDateRange(
        this.queryParam,
        this.dateRangeReceiveTime
      );

      // if (
      //   dateRangeReceiveTime !== null &&
      //   dateRangeReceiveTime !== "" &&
      //   dateRangeReceiveTime.length === 2
      // ) {
      //   queryForm.params["beginReceiveTime"] = dateRangeReceiveTime[0];
      //   queryForm.params["endReceiveTime"] = dateRangeReceiveTime[1];
      // }
      if (this.queryParam.isRep === "1") {
        this.toColumns = this.rpcolumns;
      } else {
        this.toColumns = this.columns;
      }
      alllist(queryForm).then((response) => {
        this.bizCustomerList = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 状态字典翻译
    statusFormat(row) {
      if (row.status) {
        return this.selectDictLabel(this.statusOptions, row.status);
      } else {
        return "";
      }
    },
    typeFormat(row) {
      if (row.type) {
        return this.selectDictLabel(this.typeOptions, row.type);
      } else {
        return "";
      }
    },
    levelFormat(row) {
      if (row.level) {
        return this.selectDictLabel(this.levelOptions, row.level);
      } else {
        return "";
      }
    },
    busProgressFormat(row) {
      if (row.progress) {
        return this.selectDictLabel(this.progressOptions, row.progress);
      } else {
        return "";
      }
    },
    ownTpyeFormat(row) {
      if (row.ownType) {
        return this.selectDictLabel(this.ownTypeOptions, row.ownType);
      } else {
        return "";
      }
    },
    ownTpyeRemarkFormat(row) {
      if (row.ownType) {
        return this.selectDictLabelRemark(this.ownTypeOptions, row.ownType);
      } else {
        return "";
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParam.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParam = {
        pageNum: 1,
        pageSize: 10,
        status: undefined,
      };
      this.handleQuery();
    },
    /** 翻页操作 */
    onShowSizeChange(current, pageSize) {
      this.queryParam.pageSize = pageSize;
      this.getList();
    },
    /** 翻页操作 */
    onSizeChange(current, size) {
      this.queryParam.pageNum = 1;
      this.queryParam.pageSize = size;
      this.getList();
    },
    /** 翻页操作 */
    changeSize(current, pageSize) {
      this.queryParam.pageNum = current;
      this.queryParam.pageSize = pageSize;
      this.getList();
    },
    /** 翻页操作 */
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys;
      this.selectedRows = selectedRows;
      this.ids = this.selectedRows.map((item) => item.id);
      this.single = selectedRowKeys.length !== 1;
      this.multiple = !selectedRowKeys.length;
    },
    /** 查询折叠和展开操作 */
    toggleAdvanced() {
      this.advanced = !this.advanced;
    },
    handleAdd() {
      this.showAddImportModal = true;
      this.$nextTick(() => this.$refs.bizCustomerAddForm.handleAddImport(""));
    },
    handleUpdate(record, ids) {
      this.showEditModal = true;
      this.$nextTick(() =>
        this.$refs.bizCustomerEditForm.handleUpdate(record, ids)
      );
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      var that = this;
      const bizCustomerIds = row.id || this.ids;
      this.$confirm({
        title: "确认删除所选中数据?",
        onOk() {
          return delBizCustomer(bizCustomerIds).then(() => {
            that.onSelectChange([], []);
            that.getList();
            that.$message.success("删除成功", 3);
          });
        },
        onCancel() {},
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      var that = this;
      this.$confirm({
        title: "是否确认导出?",
        content: "此操作将导出当前条件下所有数据而非选中数据",
        onOk() {
          return exportBizCustomer(that.queryParam).then((response) => {
            that.download(response.msg);
            that.$message.success("导出成功", 3);
          });
        },
        onCancel() {},
      });
    },
    // 关闭
    handleOk() {
      var that = this;
      if (that.customerInfo.userId) {
        manualShare(this.customerInfo).then((res) => {
          if (res.code === 200) {
            that.visible = false;
            that.getList();
            that.$message.success("分配成功！", 3);
          }
        });
      } else {
        that.$message.warn("请选择员工！", 3);
      }
    },
    handleCancel() {
      this.visible = false;
    },
  },
};
</script>
<style scoped lang="less">
/deep/.ant-table-body {
  min-height: calc(100vh - 400px);
}

.addJinjian {
  color: #fff;
  background-color: #67c23a;
  border-color: #67c23a;
}
.togonghai {
  color: #fff;
  background-color: #e6a23c;
  border-color: #e6a23c;
}
</style>
